from app.database import convert
from app.models.po.gaolu.gaolu_diagnose_data import GaoLuDiagnoseDataPO

from app.exts import mysql_pool


def get_score(start,end):
    conn, cursor = mysql_pool.connect("ironman")
    sql = """
    select zt+ltlg+zb+cz as score,date_time from gaolu_diagnose_score where date_time >='{}'
    and date_time <='{}'
    """.format(start,end)

    cursor.execute(sql)
    results = cursor.fetchall()

    mysql_pool.connect_close(conn, cursor)

    return results

def get_records(start,end):
    conn, cursor = mysql_pool.connect("ironman")
    sql = """
    select gaolu_diagnose_data.*,
    gaolu_diagnose_score.zf,
    gaolu_diagnose_score.zt,
    gaolu_diagnose_score.zb,
    gaolu_diagnose_score.cz,
    gaolu_diagnose_score.ltlg from gaolu_diagnose_score,gaolu_diagnose_data where gaolu_diagnose_data.date_time >='{}'
    and gaolu_diagnose_data.date_time <='{}' and gaolu_diagnose_score.date_time = gaolu_diagnose_data.date_time order by gaolu_diagnose_data.id desc
    """.format(start,end)

    cursor.execute(sql)
    results = cursor.fetchall()

    mysql_pool.connect_close(conn, cursor)

    return results
